<?php

if(empty($_FILES)){
	exit("文件过大，受post约束");
}

$file = current($_FILES);

foreach ($file['name'] as $k => $v) {
	

	if($file['error'][$k]>0){
		exit("上传有错，错误代码是：".$file['error'][$k]);
	}

	$allow = ['jpg','png','gif'];

	$suffixArr = explode('.', $file['name'][$k]);

	$suffix =  end($suffixArr);

	$name = uniqid().mt_rand(1000,9999).".".$suffix;


	is_dir('./upload') || mkdir("./upload");

	$path = "./upload/".$name;

	move_uploaded_file($file['tmp_name'][$k],$path);

}
header("Location:./index.php");